export class Result {
  data?: any;
  message: string;
  code: number;

  constructor(code: number, message?: string, data?: any) {
    this.data = data || null;
    this.message = message || '操作成功';
    this.code = code;
  }

  static success(data?: any, message?: string): Result {
    return new Result(200, message, data);
  }

  static fail(message: string = '操作失败', code: number = 500): Result {
    return new Result(code, message);
  }
}
